<script setup lang="ts" name="SystemSocialUserDetail">
import { DICT_TYPE } from '@/enums/dictEnums'
import { SocialUserApi, SocialUserType } from '@/api/system/social/user'

const { t } = useI18n() // 国际化
const visible = ref(false) // 弹窗的是否展示
const detailLoading = ref(false) // 表单的加载中
const detailData = ref({} as SocialUserType) // 详情数据

/** 打开弹窗 */
const open = async (id: number) => {
  visible.value = true
  // 设置数据
  try {
    detailData.value = await SocialUserApi.detail(id)
  } finally {
    detailLoading.value = false
  }
}
defineExpose({ open }) // 提供 open 方法，用于打开弹窗
</script>

<template>
  <Dialog v-model="visible" :title="t('sys.social.user', 'detail')" height="50vh" type="scroll" width="800px">
    <el-descriptions :column="1" border>
      <el-descriptions-item :label="t('sys.social.user', 'type')" min-width="120">
        <dict-tag :type="DICT_TYPE.SYSTEM_SOCIAL_TYPE" :value="detailData.type" />
      </el-descriptions-item>
      <el-descriptions-item :label="t('sys.social.user', 'nickname')">
        {{ detailData.nickname }}
      </el-descriptions-item>
      <el-descriptions-item :label="t('sys.social.user', 'avatar')">
        <el-image :src="detailData.avatar" class="h-30px w-30px" />
      </el-descriptions-item>
      <el-descriptions-item :label="t('sys.social.user', 'token')">
        {{ detailData.token }}
      </el-descriptions-item>
      <el-descriptions-item :label="t('sys.social.user', 'rawTokenInfo')">
        <el-input v-model="detailData.rawTokenInfo" :autosize="{ maxRows: 20 }" :readonly="true" type="textarea" />
      </el-descriptions-item>
      <el-descriptions-item :label="t('sys.social.user', 'rawUserInfo')">
        <el-input v-model="detailData.rawUserInfo" :autosize="{ maxRows: 20 }" :readonly="true" type="textarea" />
      </el-descriptions-item>
      <el-descriptions-item :label="t('sys.social.user', 'code')">
        {{ detailData.code }}
      </el-descriptions-item>
      <el-descriptions-item :label="t('sys.social.user', 'state')">
        {{ detailData.state }}
      </el-descriptions-item>
    </el-descriptions>
  </Dialog>
</template>

<style scoped lang="scss"></style>
